import http from '@/service/http'
import type * as T from '@/types/api/index'
const dictApi: T.IDictApi = {
  list(params) {
    return http.get('/admin/dict/list', params)
  },
  typeList(type) {
    return http.get(`/admin/dict/type/${type}`)
  },
  add(data) {
    return http.post('/admin/dict', data)
  },
  edit(data) {
    return http.put('/admin/dict', data)
  },
  del(data) {
    return http.delete('/admin/dict', data.ids)
  },
  listItem(params) {
    if (!params.label) {
      delete params.label
    }
    return http.get('/admin/dict/item/page', params)
  },
  addItem(data) {
    return http.post('/admin/dict/item', data)
  },
  editItem(data) {
    return http.put('/admin/dict/item', data)
  },
  delItem(data) {
    return http.delete(`/admin/dict/item/${data.ids[0]}`)
  },
  remove() {
    return http.put('/admin/dict/sync')
  },
}

export default dictApi
